public class test1_2 {
    //力扣 3.无重复的最长子串
    //自己写的
    public static void main(String[] args) {
        String s = "tmmzuxt";

        char[] chars = s.toCharArray();
        int n = chars.length;
        if(n==0){
            System.out.println(0);
            System.exit(0);
        }
        int left = 0;
        int right = 0;
        int max = 0;
        while (right<n){
            int  flag=contins(left,right,chars);
            if (flag!=-1){
                max = max>right-left?max:right-left;
                left=flag+1;

            }
            right++;
        }
        max = max>right-left?max:right-left;
        System.out.println(max);
    }

    private static int contins(int left, int right, char[] chars) {

        for (;left<right;left++){
            if(chars[left]==chars[right]){
                return left;
            }
        }
        return -1;
    }
}
